#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QtGui>
#include "ui_mainwindow.h"
#include "viewer.h"
#include "transferfunctionmanager.h"
#include "transferfunctioneditorwidget.h"
#include "lightingwidget.h"
#include "keyframe.h"
#include "keyframeeditor.h"
#include "renderprocess.h"

class MainWindow : public QMainWindow
{
  Q_OBJECT

  public :
    MainWindow(QWidget *parent=0);

  protected slots :
    void closeEvent(QCloseEvent *event);
    void dragEnterEvent(QDragEnterEvent*);
    void dropEvent(QDropEvent*);

  private slots :
    void glewInit();
    void on_actionExit_triggered();
    void on_actionImage_Size_triggered();
    void on_actionLoad_Volume_triggered();
    void on_actionSave_ImageSequence_triggered();
    void on_actionLoad_Project_triggered();
    void on_actionSave_Project_triggered();
    void on_actionSave_ProjectAs_triggered();

    void on_actionStatusBar_triggered();
    void on_actionSwitch_To1D_triggered();

    void on_actionRaycast_triggered();

    void on_actionSpline_PositionInterpolation_triggered();

    void openRecentFile();   

    void changeTransferFunctionDisplay(int, QList<bool>);
    void checkStateChanged(int, int, bool);
    void updateComposite();
    void applyTFUndo(bool);
    void transferFunctionUpdated();
    void changeHistogram(int);

    void setKeyFrame(Vec, Quaternion,
		     int,
		     Vec, int,
		     QImage,
		     Vec, Vec,
		     float*);

   void updateMorph(bool);
   void updateTransferFunctionManager(QList<SplineInformation>);

  signals :
    void histogramUpdated(QImage, QImage);
    void playKeyFrames(int, int, int);

  private :
    Ui::MainWindow ui;

    QStackedWidget *m_stackedWidget;

    QTextEdit *m_log;
    Viewer *m_Viewer;
    Viewer *m_ViewerRaycast;
    
    TransferFunctionContainer *m_tfContainer;
    TransferFunctionManager *m_tfManager;
    TransferFunctionEditorWidget *m_tfEditor;
    
    LightingWidget *m_lightingWidget;

    QDockWidget *m_dockKeyframe;
    KeyFrame *m_keyFrame;
    KeyFrameEditor *m_keyFrameEditor;

    RenderProcess *m_renderProcess;

    QList <QAction*> m_recentFileActions;

   void loadSettings();
   void saveSettings();

   void loadVolume(QString);
   void loadVolume(QList<QString>);

   void loadProject(const char*);
   void saveProject(const char*);

   QList<QString> loadVolumeFromProject(const char*);
   void saveVolumeIntoProject(const char*);

   void loadViewsAndKeyFrames(const char*);
   void saveViewsAndKeyFrames(const char*);

   void initializeRecentFiles();
   void updateRecentFileAction();

};

#endif
